/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.squirrelm.my;

import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

/**
 *
 * @author Administrator
 */
public class PersistenceManagerHolder {
    
    protected PersistenceManagerFactory pmf;

    protected PersistenceManager  pm  = null;
    
    public void init()
    {
        pm  = pmf.getPersistenceManager();
    }

    public void setPmf(PersistenceManagerFactory pmf) {
        this.pmf = pmf;
    }

    public PersistenceManager get()
    {
        return pm;
    }
    
    public void destroy()
    {
        if (pm != null && !pm.isClosed())
        {
            pm.close();
        }
    }
}
